import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		tabbar:1,
		videoNavid:0,
	},
	mutations: {
		setTab(state,plyload){
			console.log(plyload,'setTabsetTab');
			state.tabbar = plyload
		},
		setvideoNavid(state,plyload){
			console.log(plyload,'videoNavid');
			state.videoNavid = plyload
		}
	},
	plugins: [
		createPersistedState({
			key: 'storeOne',
			paths: [
				'tabbar', 
				'videoNavid'
			],
			storage: {
				getItem: (key) => uni.getStorageSync(key), // 获取
				setItem: (key, value) => uni.setStorageSync(key, value), // 存储
				removeItem: (key) => uni.removeStorageSync(key) // 删除
			}
		})
	
	]
})

export default store
